package com.flash.BusinessData.controller;

import com.flash.BusinessData.entity.securityAccrued;
import com.flash.BusinessData.service.SecurityAccruedService;
import com.flash.GlobalManagement.util.Dbutil;
import com.flash.GlobalManagement.util.TableIdUtil;
import com.flash.GlobalManagement.util.TableNameUtil;
import com.flash.GlobalManagement.util.TableTimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/*
证券应收应付
 */
@RestController
public class securityAccruedController {
    @Autowired
    private SecurityAccruedService securityAccruedService;

    @Resource
    Dbutil dbutil;

    @RequestMapping("securityAccruedSelect")
    public Map securityAccruedSelect(int page , int limit, securityAccrued securityAccrued){
        System.out.println("123");
        List<securityAccrued> securityAccrueds = securityAccruedService.securityAccruedSelect(page, limit,securityAccrued);
        int i = securityAccruedService.CountSecurityAccrued();
        Map map =new HashMap();
        map.put("code","0");
        map.put("msg","");
        map.put("count",i);
        map.put("data",securityAccrueds);
        return map;
    }


    @RequestMapping("securityAccruedInsert")
    public int securityAccruedInsert(securityAccrued securityAccrued,HttpServletRequest request){
        securityAccrued.setSecurityAccruedId(dbutil.getMaxId(TableIdUtil.SAID, TableNameUtil.SA, TableTimeUtil.SATime));
        HttpSession session = request.getSession();
        securityAccrued.setFundId((String) session.getAttribute("fundId"));
        int i = securityAccruedService.SecurityAccruedInsert(securityAccrued);
        System.out.println("我是 添加 ");

        return i;
    }


    @RequestMapping("securityAccruedDelete")
    public int securityAccruedDelete(String securityAccruedId){
        int i = securityAccruedService.SecurityAccruedDelete(securityAccruedId);
        System.out.println("我是 删除 ");
        return i;
    }

    @RequestMapping("securityAccruedUpdate")
    public int securityAccruedUpdate(securityAccrued securityAccrued){
        int i = securityAccruedService.SecurityAccruedUpdate(securityAccrued);
        System.out.println("我是 修改 ");
        return i;
    }
}
